#include "m.h"


void caxun(p_list head)
{
int choice;
char info[20];
p_list node;

while(1)
{
    czjm2();
    printf("+++++++++++++\n");
    printf("请输入您的选择\n");
    scanf("%d",&choice);
    bzero(info,20);
    int fun=0;


    switch(choice)
    {   
    case 1:
        printf("请输入你要查询的学号\n");
        scanf("%s",info);
        
        list_for_each_entry(node, &(head->list), list)
        {
            if(strcmp(node->number,info)==0)
            {
            printf("学号：%s\t 姓名：%s\t 年龄：%d\t 电话：%s\t 宿舍号：%s\t", node->number,node->name,node->age,node->tel,node->ssh);  
            printf("\n");
            return;
            }
        
        }
        printf("未找到该学生\n");       
        return;

    case 2:
        printf("请输入你要查询的名字\n");
        scanf("%s",info);
        
        list_for_each_entry(node, &(head->list), list)
        {
            if(strcmp(node->name,info)==0)
            {
            printf("学号：%s\t 姓名：%s\t 年龄：%d\t 电话：%s\t 宿舍号：%s\t", node->number,node->name,node->age,node->tel,node->ssh);  
            printf("\n");
            fun=1;
            }
             
        }
        if(fun==0){
        printf("未找到该学生\n");
        }
        return;

    case 3:
        printf("请输入你要查询的宿舍号\n");
        scanf("%s",info);
        
        list_for_each_entry(node, &(head->list), list)
        {
            if(strcmp(node->ssh,info)==0)
            {
            printf("学号：%s\t 姓名：%s\t 年龄：%d\t 电话：%s\t 宿舍号：%s\t", node->number,node->name,node->age,node->tel,node->ssh);  
            printf("\n");
            fun=1;
            }
          
        }
        if(fun==0){
        printf("未找到该宿舍的学生\n");
        }
        return;
    
    case 4:
        return;
    
    default:
        printf("输入有误，请重新输入\n");
        break;

    }


}

}